﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BoCaiWeb.WebSite.Code;
using BoCaiWeb.Model;
using BoCaiWeb.Business;
using Ajeelee.Core.Database;
using System.Collections;
using Ajeelee.Core.Utils;

namespace BoCaiWeb.WebSite.WebAdmin
{
    public partial class MessageList : AuthPageBase
    {
        protected string mname = "", content = "";
        protected IList<Message> messageList = new List<Message>();
        IMessageBusiness messageBll = new MessageBusinessFactory().CreateMessageBusiness();
        PageStructure ps = new PageStructure() { PageSize = 15, CurrPage = 1 };

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            try
            {
                mname = QueryParam("mname");
                content = QueryParam("content");

                // 删除
                if (!string.IsNullOrEmpty(QueryParam("d")) && QueryParamInt32("d") > 0)
                {
                    messageBll.Delete(QueryParamInt32("d"));
                }

                Hashtable ht = new Hashtable();
                ht.Add(MessageHash.Username, Function.SafeSqlLiteral(mname));
                ht.Add(MessageHash.Content, Function.SafeSqlLiteral(content));
                messageList = messageBll.GetAllMessageByPage(ht, ps);
                pager1.PageStruct = ps;
            }
            catch (Exception ex)
            {
                Function.WriteErrorLog(ex);
            }
        }
    }
}